//== SAGITTARIUS ============================================================================

//== BEGINNING OF CODE ===============================================================

#include <stdio.h>
#include <string.h>
#include <malloc.h>

typedef struct {
    char* str;
    size_t l;
} lenstr_t;

//int is used for type of "chr" because getc returns int
lenstr_t* append(lenstr_t* a, int chr) {
    if(chr == EOF) {
        if(a) {
            free(a->str);
            free(a);
        }
        return NULL;
    } else {
        size_t l = a ? a->l : 0; //base length
        lenstr_t* r=malloc(sizeof(lenstr_t));
        r->str = malloc(l+1);
        if(a) {
            memcpy(r->str, a->str, a->l);
            free(a->str);
            free(a); //a is no longer needed
        }
        r->str[l] = chr;
        r->l = l+1;
        return r;
    }
}

int main(int argc, char* argv[]) {
    lenstr_t* a=NULL;
    while((a = append(a, getc(stdin))))
        printf("%.*s\n", a->l, a->str);
    
    return 0;
}
